﻿    <UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule.GroupTree"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" AutomationProperties.AutomationId="AIDGroupTree"
        Height="200" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
        <UserControl.Resources>
            <Style x:Key="TreeViewStyle1" TargetType="{x:Type TreeView}">
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
                <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Padding" Value="1"/>
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TreeView}">
                            <Border SnapsToDevicePixels="true" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <ScrollViewer Focusable="false" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CanContentScroll="false" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" Template="{DynamicResource ScrollViewerControlTemplate3}">
                                    <ItemsPresenter/>
                                </ScrollViewer>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <HierarchicalDataTemplate x:Key="ParentActivityTemplate" ItemsSource="{Binding Path=Children}">
                <Grid PreviewMouseDown="Grid_PreviewMouseDown">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="21.5"/>
                        <ColumnDefinition Width="*" MinWidth="26.098"/>
                    </Grid.ColumnDefinitions>
                    <Image Grid.ColumnSpan="1" Width="16" HorizontalAlignment="Center" Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ManagementStudio/groups.png" VerticalAlignment="Center" Height="16" />
                    <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=Name}" AutomationProperties.AutomationId="{Binding Path=Name}"/>
            </Grid>
            </HierarchicalDataTemplate>
        </UserControl.Resources>

        <Grid HorizontalAlignment="Stretch">
            <TreeView HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Style="{DynamicResource TreeViewStyle1}" 
                  SelectedItemChanged="OnSelectedItemChanged" x:Name="userTreeview" 
                  ItemContainerStyle="{DynamicResource TreeViewItemStyleCustomImage}" ItemTemplate="{StaticResource ParentActivityTemplate}"
                  ItemsSource="{Binding Path=LeftPaneTreeItems}"/>
        </Grid>
    </UserControl>

